package com.krmes.mes.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class TimeZoneUtil {
    public static boolean isInEasternEightZones() {
        if (TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08")) {
            return true;
        }
        return false;
    }

    public static Date transformTime(Date date, TimeZone oldZone, TimeZone newZone) {
        if (date == null) {
            return null;
        }
        return new Date(date.getTime() - ((long) (oldZone.getOffset(date.getTime()) - newZone.getOffset(date.getTime()))));
    }

    public static String getCurrentTime() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis()));
    }

    public static String getCurrentTimeSpan() {
        return System.currentTimeMillis() + "-" + Thread.currentThread().getId();
    }
}
